package net.ojbk.timeSpace.timeAxis.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import net.ojbk.timeSpace.timeAxis.beans.TimeAxis;
import net.ojbk.timeSpace.timeAxis.beans.TimeBlade;
import net.ojbk.timeSpace.timeAxis.dao.TimeAxisDao;
import net.ojbk.timeSpace.timeAxis.dao.TimeBladeDao;
import net.ojbk.timeSpace.timeAxis.service.IAxisService;

@Service("axisService")
public class AxisServiceImpl implements IAxisService {
	@Autowired
	@Qualifier("TimeAxisDao")
	private TimeAxisDao timeAxisDao;
	
	@Autowired
	@Qualifier("TimeBladeDao")
	private TimeBladeDao timeBladeDao;
	
	@Override
	public List<TimeAxis> getAllAxis() {
		// TODO Auto-generated method stub
		return timeAxisDao.selectAllRecord();
	}

	@Override
	public TimeAxis getOneAxis(int axisId) {
		// TODO Auto-generated method stub
		return timeAxisDao.selectOneRecord(axisId);
	}

	@Override
	public List<TimeBlade> getAllBladeByAxisId(int axisId) {
		// TODO Auto-generated method stub
		return timeBladeDao.selectAllRecordByAxisId(axisId);
	}

	@Override
	public void modifyMsgPw(TimeAxis axis, String newPw) {
		// TODO Auto-generated method stub
		axis.setMsgPw(newPw);
		timeAxisDao.updateOneRecord(axis);
	}

	@Override
	public Boolean checkMsgPw(String yourPw, TimeAxis axis) {
		// TODO Auto-generated method stub
		if(axis.getMsgPw().equals(yourPw)) {
			return true;
		}
		else
			return false;
	}

	@Override
	public void addTimeBlade(TimeAxis axis, TimeBlade newBlade) {
		// TODO Auto-generated method stub
		newBlade.setAxisId(axis.getAxisId());
		timeBladeDao.updateOneRecord(newBlade);
	}

}
